package cn.kgc.springboot.day01;

import cn.kgc.springboot.day01.controller.HelloController;
import cn.kgc.springboot.day01.entity.User;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

/**
 * springboot项目的启动类  @SpringBootApplication  组合注解
 *
 * @ComponentScan               包扫描的注解  默认扫描启动类所在的包及其子包
 * @SpringBootConfiguration  @Configuration    完成springboot工程的默认配置   被 @Configuration  所修饰的类就是配置类 类似 xml文件
 * @EnableAutoConfiguration   开启自动化配置    spring+springmvc   第三方框架的配置  整合
 */
@SpringBootApplication
public class SpringbootDay0101Application {

    public static void main(String[] args) {
        // 创建 spring工厂
        ConfigurableApplicationContext applicationContext = SpringApplication.run(SpringbootDay0101Application.class, args);

        // 从spring的工厂中获取实例对象
        HelloController bean1 = applicationContext.getBean(HelloController.class);
        System.out.println("bean1 = " + bean1);

        User bean = applicationContext.getBean(User.class);
        System.out.println("bean = " + bean);

    }

}
